package struts.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import struts.dao.UserDAO;
import struts.model.User;

@Component
public class UserService {
	private UserDAO userDAO;
	
	public void add(User user) {
		userDAO.save(user);
	}
	
	public void remove(User user) {
		userDAO.delete(user);
	}
	
	public void update(User user) {
		userDAO.update(user);
	}
	
	public List<User> listAll() {
		List<User> users = userDAO.loadAll();
		return users;
	}
	
	public User list(int id) {
		User user = userDAO.load(id);
		return user;
	}

	public UserDAO getUserDAO() {
		return userDAO;
	}

	@Resource
	public void setUserDAO(UserDAO userDAO) {
		this.userDAO = userDAO;
	}
}
